babl.git
7 years agoextensions: add more u32 short cut utility conversions
Øyvind Kolås [Sat, 7 Apr 2018 15:04:56 +0000 (17:04 +0200)]
extensions: add more u32 short cut utility conversions

7 years agoextensions: u32<->float conversions in simple extension
Øyvind Kolås [Sat, 7 Apr 2018 15:01:08 +0000 (17:01 +0200)]
extensions: u32<->float conversions in simple extension

They were using 'float' rather than 'double' data types for intermediate values
the lack of precision made the conversions be discarded by babl.

7 years agoextensions: add missing 32bit.c
Øyvind Kolås [Fri, 6 Apr 2018 11:14:34 +0000 (13:14 +0200)]
extensions: add missing 32bit.c

7 years agoextensions: add some u32 fast paths
Øyvind Kolås [Fri, 6 Apr 2018 10:40:46 +0000 (12:40 +0200)]
extensions: add some u32 fast paths

7 years agofloat-half: half fast paths for premultiplied alpha
Øyvind Kolås [Thu, 5 Apr 2018 22:53:16 +0000 (00:53 +0200)]
float-half: half fast paths for premultiplied alpha

7 years agoextensions: add a double extension
Øyvind Kolås [Thu, 5 Apr 2018 21:24:31 +0000 (23:24 +0200)]
extensions: add a double extension

This will permit slightly faster than the generic fast paths for some possibly
desired intermediate conversions. This also adds alpha stripping - which fills
in the last babl fast path currently reported missing on every launch of GIMP.

7 years agoextensions: simplify gggl/conv_rgbF_rgbaF slightly
Øyvind Kolås [Wed, 4 Apr 2018 22:39:23 +0000 (00:39 +0200)]
extensions: simplify gggl/conv_rgbF_rgbaF slightly

7 years agoextensions/cairo: optimize R'G'B'A u8 to cairo-ARGB32
Øyvind Kolås [Wed, 4 Apr 2018 22:15:08 +0000 (00:15 +0200)]
extensions/cairo: optimize R'G'B'A u8 to cairo-ARGB32

A combination of SIMD paths via float was beating the naive implementation in
the cairo extension, now the cairo extension comes out on top again.

7 years agoextension: add some Y' u8 fast paths
Øyvind Kolås [Wed, 4 Apr 2018 21:49:55 +0000 (23:49 +0200)]
extension: add some Y' u8 fast paths

GIMP makes use of "Y' u8" to "R'G'B' u8" and we had no paths covering it,
making it go through floating point. This commit adds code paths for expanding
single grayscale u8 to R'G'B and R'G'B'A as well as R'aG'aB'aA u8.

7 years agoextensions/gegl-fixups: swap increments of src and dst in rgba8_rgb8
Øyvind Kolås [Wed, 4 Apr 2018 14:41:51 +0000 (16:41 +0200)]
extensions/gegl-fixups: swap increments of src and dst in rgba8_rgb8

They were reversed, causing memory corruptions fixing bugs 794973 and 794972.

7 years agoextensions: add rgba8_rgb8 conversion that copies 24/32bit chunks
Øyvind Kolås [Wed, 4 Apr 2018 12:09:54 +0000 (14:09 +0200)]
extensions: add rgba8_rgb8 conversion that copies 24/32bit chunks

Slightly speeding up RGB u8 (without alpha) painting in GIMP, the rgba to rgb
and reverse conversions are used together with the very fast SIMD conversions
that operate on chunks of 4 components.

8 years agopost release version bump
Øyvind Kolås [Sun, 18 Feb 2018 11:29:35 +0000 (12:29 +0100)]
post release version bump

8 years agorelease 0.1.44
Øyvind Kolås [Sun, 18 Feb 2018 11:27:46 +0000 (12:27 +0100)]
release 0.1.44

8 years agobabl: fix minor leak reported in bug #790924
Øyvind Kolås [Wed, 7 Feb 2018 18:53:48 +0000 (19:53 +0100)]
babl: fix minor leak reported in bug #790924

8 years agoAdded mingw template pkgbuild.
Félix Piédallu [Mon, 29 Jan 2018 12:48:26 +0000 (13:48 +0100)]
Added mingw template pkgbuild.

8 years agoFix windows dirs_sep. Cleanup.
Félix Piédallu [Thu, 11 Jan 2018 20:32:57 +0000 (21:32 +0100)]
Fix windows dirs_sep. Cleanup.

8 years agoRemove check for linux header on win32
Félix Piédallu [Thu, 11 Jan 2018 20:26:34 +0000 (21:26 +0100)]
Remove check for linux header on win32

8 years agoRemove os_win32
Félix Piédallu [Thu, 11 Jan 2018 20:25:50 +0000 (21:25 +0100)]
Remove os_win32

8 years agoTemporarily disable checking for headers
Félix Piédallu [Tue, 9 Jan 2018 20:48:01 +0000 (21:48 +0100)]
Temporarily disable checking for headers

8 years agoPKGBUILD points again to gnome upstream
Félix Piédallu [Mon, 18 Dec 2017 14:14:29 +0000 (15:14 +0100)]
PKGBUILD points again to gnome upstream

8 years agoFix : libdir for autotools and meson are not the same…
Félix Piédallu [Mon, 18 Dec 2017 14:06:57 +0000 (15:06 +0100)]
Fix : libdir for autotools and meson are not the same…

8 years agobabl: fix icc matrix profile fast paths
Øyvind Kolås [Tue, 30 Jan 2018 15:35:28 +0000 (16:35 +0100)]
babl: fix icc matrix profile fast paths

For core members, babl relies on shared data layout between fish and
conversion to be able to do dispatch, and have source/target match -
though only for simple fishes.

The ICC fast path conversions also used the user data - but directly
instead of throug the argument, changing this makes the matrix and
luts work again - and let the conversions be used.

8 years agomeson: Add missing single quote
Jan Vesely [Wed, 24 Jan 2018 23:51:58 +0000 (18:51 -0500)]
meson: Add missing single quote

Fixes build since ad0eac19c7a1f0046979ad8923f6ac1b7c2d7696 ("release 0.1.42")

Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
8 years agopost release version bump
Øyvind Kolås [Tue, 23 Jan 2018 15:36:04 +0000 (16:36 +0100)]
post release version bump

8 years agorelease 0.1.42
Øyvind Kolås [Tue, 23 Jan 2018 15:09:34 +0000 (16:09 +0100)]
release 0.1.42

8 years agobabl: initialize the bpp of fishes loaded from cache
Øyvind Kolås [Sat, 20 Jan 2018 17:41:12 +0000 (18:41 +0100)]
babl: initialize the bpp of fishes loaded from cache

The cache loading code manually constructs path fishes, which did not
get their bpp initialized, this resulted in conversions of long runs to
fail, not crash - but stop processing after MAX_BUFFER_SIZE pixels.

8 years agopost release version bump
Øyvind Kolås [Wed, 17 Jan 2018 03:07:30 +0000 (04:07 +0100)]
post release version bump

8 years agoNEWS: update
Øyvind Kolås [Tue, 16 Jan 2018 17:48:35 +0000 (18:48 +0100)]
NEWS: update

8 years agorelease 0.1.40
Øyvind Kolås [Tue, 16 Jan 2018 17:38:49 +0000 (18:38 +0100)]
release 0.1.40

8 years agobabl: add a test iteration multiplier
Øyvind Kolås [Wed, 17 Jan 2018 02:57:23 +0000 (03:57 +0100)]
babl: add a test iteration multiplier

On my system many of the conversions got measured to costs of 3 4 and 5, these
makes a big room for measurement errors, to increase reliability the tests are
now run 4 times - making it a ranking of contenders with fewer collisions.

This will slightly increase incurred delayed on search for conversions.

8 years agobabl: make pixel-count instrumentation opt-in
Øyvind Kolås [Wed, 17 Jan 2018 02:46:59 +0000 (03:46 +0100)]
babl: make pixel-count instrumentation opt-in

Checking if an integer is 0/1 is lower overhead than incrementing a long stored
kt a memory location. As a side effect, the entries in
~/.cache/babl/babl-fishes will not be sorted by most used to least used unless
the BABL_INSTRUMENT environment variable is set to a value.

8 years agobabl: set user_data ptr for quick dispatch of 1 step path
Øyvind Kolås [Tue, 16 Jan 2018 17:34:46 +0000 (18:34 +0100)]
babl: set user_data ptr for quick dispatch of 1 step path

8 years agobabl: indentation and code cleanup
Øyvind Kolås [Tue, 16 Jan 2018 17:12:47 +0000 (18:12 +0100)]
babl: indentation and code cleanup

8 years agobabl: use memcpy dpsatch path for all identity transforms
Øyvind Kolås [Mon, 15 Jan 2018 21:41:03 +0000 (22:41 +0100)]
babl: use memcpy dpsatch path for all identity transforms

8 years agobabl: reduce amount of instrumentation
Øyvind Kolås [Mon, 15 Jan 2018 13:21:59 +0000 (14:21 +0100)]
babl: reduce amount of instrumentation

The integer counter for number of processings overflows in some scenarios, thus
cannot be relied on for more than being informative.

We might ultimately want to also drop the instrumentation.

8 years agobabl: store pointer to where user data resides instead of copy
Øyvind Kolås [Sun, 14 Jan 2018 22:55:53 +0000 (23:55 +0100)]
babl: store pointer to where user data resides instead of copy

This will make the scenario of changing user data work, we do it
unconditionally to avoid introducing a branch.

8 years agobabl: refactor code to get rid of more branches in babl_process
Øyvind Kolås [Sun, 14 Jan 2018 21:49:40 +0000 (22:49 +0100)]
babl: refactor code to get rid of more branches in babl_process

In the best case scenario now, babl_process increments instrumentation
counters and directly calls the relevant registered fast path function,
with no additional call stack frames in-between.

8 years agobabl: use babl_conversion_process where appropriate
Øyvind Kolås [Sun, 14 Jan 2018 21:15:12 +0000 (22:15 +0100)]
babl: use babl_conversion_process where appropriate

Instead of overloading babl_process() with two tasks, both fishes and
conversions, use the conversion specific API for conversions directly.

8 years agobabl: simplify branching in babl_process dispatch
Øyvind Kolås [Sun, 14 Jan 2018 20:44:18 +0000 (21:44 +0100)]
babl: simplify branching in babl_process dispatch

8 years agobabl: factor out some branches from path fish dispatch
Øyvind Kolås [Sun, 14 Jan 2018 18:19:30 +0000 (19:19 +0100)]
babl: factor out some branches from path fish dispatch

8 years agobabl: refactor conversion dispatch to do less branches at runtime
Øyvind Kolås [Sun, 14 Jan 2018 17:36:26 +0000 (18:36 +0100)]
babl: refactor conversion dispatch to do less branches at runtime

8 years agobabl.map: update symbols for meson build
Øyvind Kolås [Sat, 13 Jan 2018 14:43:01 +0000 (15:43 +0100)]
babl.map: update symbols for meson build

8 years agobabl: add babl_process_rows api
Øyvind Kolås [Sun, 7 Jan 2018 00:10:54 +0000 (01:10 +0100)]
babl: add babl_process_rows api

Useful when fetching buffers smaller than a tile or partial tiles in APIs like
gegl_buffer_get.

8 years agosse2-float: use same TRC for "leftover" samples
Ell [Sat, 13 Jan 2018 09:02:24 +0000 (04:02 -0500)]
sse2-float: use same TRC for "leftover" samples

The SSE2 versions of the gamma <-> linear TRC functions can produce
slightly different results than the scalar ones.  Consequently,
last commit didn't resolve all discrepancies between the main and
leftover samples (and didn't address the gamma -> linear
direction).

Use the same SSE2 TRC functions for converting the leftover
samples, rather than the scalar functions, to fix that.

8 years agosse2-float: use babl_linear_to_gamma_2_2f() (instead of double)
Ell [Thu, 11 Jan 2018 14:22:46 +0000 (09:22 -0500)]
sse2-float: use babl_linear_to_gamma_2_2f() (instead of double)

Use the single-precision babl_linear_to_gamma_2_2f() function,
instead of the double-precision version, when converting "leftover"
samples, so that the result is consistent with the vectorized
samples.

8 years agoutil, sse2-float: make sure 1 maps to 1 in linear -> gamma conversions
Ell [Thu, 11 Jan 2018 14:19:50 +0000 (09:19 -0500)]
util, sse2-float: make sure 1 maps to 1 in linear -> gamma conversions

Add a small offset to the result of the linear -> gamma
conversions, such that an input value of 1.0 maps to an output
value of 1.0, exactly.

8 years agobabl: shuffle some dispatch functions to be inlineable
Øyvind Kolås [Sun, 7 Jan 2018 04:37:39 +0000 (05:37 +0100)]
babl: shuffle some dispatch functions to be inlineable

8 years agobabl: strip out some internal length returning code
Øyvind Kolås [Sat, 6 Jan 2018 23:42:33 +0000 (00:42 +0100)]
babl: strip out some internal length returning code

8 years agobabl: prepare babl_fish_process for direct calling
Øyvind Kolås [Sat, 6 Jan 2018 23:35:22 +0000 (00:35 +0100)]
babl: prepare babl_fish_process for direct calling

8 years agopalette: expect palettes/formats to be gamma corrected in 8bit
Øyvind Kolås [Wed, 3 Jan 2018 16:12:41 +0000 (17:12 +0100)]
palette: expect palettes/formats to be gamma corrected in 8bit

A correctness correction related to bug #763581 the formats wanted
by GIMP and expected are gamma corrected not linear, I expect this
fix either does not much for GIMP or fixes an unknown 8bit linear
vs gamma quantization problem that has been lurking in INDEXED mode.

8 years agobabl: improve babl_trc_formula_srgb sRGB detection constants
Øyvind Kolås [Tue, 2 Jan 2018 20:05:02 +0000 (21:05 +0100)]
babl: improve babl_trc_formula_srgb sRGB detection constants

For bug #791816. Use constants as passed from GIMP when its built in sRGB ICC
profile is passed.

8 years agoCIE: Use a faster cbrtf implementation
Debarshi Ray [Thu, 21 Dec 2017 09:14:53 +0000 (10:14 +0100)]
CIE: Use a faster cbrtf implementation

This is the approximate cube root of an IEEE float implementation from
Hacker's Delight. The elimination of all conditional branches probably
makes it a better candidate for future SIMD accelerated code paths.

On an Intel i7 Haswell, it now takes 0.27s to convert a 15 megapixel
buffer from "RGBA float" to "CIE Lab alpha float" instead of the
earlier 0.35s. A "Y float" to "CIE L float" conversion takes 0.085s
instead of 0.102s.

Original code: http://www.hackersdelight.org/hdcodetxt/acbrt.c.txt
Permissions: http://www.hackersdelight.org/permissions.htm

https://bugzilla.gnome.org/show_bug.cgi?id=791837

8 years agoextensions-gggl: clamp when converting float to 16bit
Øyvind Kolås [Wed, 20 Dec 2017 02:22:22 +0000 (03:22 +0100)]
extensions-gggl: clamp when converting float to 16bit

Improve the quality of a conversion that was picked in error for bug #790658

8 years agobabl: re-enable earlier bailing for big path errors
Øyvind Kolås [Wed, 20 Dec 2017 02:22:00 +0000 (03:22 +0100)]
babl: re-enable earlier bailing for big path errors

This is one way of dealing with 790658 - that in general is a good idea as
well.

8 years agomeson.build: babl's license is LGPL3+
Øyvind Kolås [Tue, 19 Dec 2017 01:13:26 +0000 (02:13 +0100)]
meson.build: babl's license is LGPL3+

8 years agoSimpler library handling. PKGBUILD+release, lto.
Félix Piédallu [Fri, 15 Dec 2017 09:54:49 +0000 (10:54 +0100)]
Simpler library handling. PKGBUILD+release, lto.

8 years agofix check version
Félix Piédallu [Thu, 14 Dec 2017 14:52:57 +0000 (15:52 +0100)]
fix check version

8 years agoFix library name
Félix Piédallu [Thu, 14 Dec 2017 14:52:47 +0000 (15:52 +0100)]
Fix library name

8 years agoAdded PKGBUILD for archlinux, based on AUR.
Félix Piédallu [Thu, 14 Dec 2017 14:12:25 +0000 (15:12 +0100)]
Added PKGBUILD for archlinux, based on AUR.

8 years agoRemove useless join_paths arg
Félix Piédallu [Wed, 6 Dec 2017 14:22:41 +0000 (15:22 +0100)]
Remove useless join_paths arg

8 years agouse find_program. Use env for multiple commands as it allows to split into string...
Félix Piédallu [Sat, 2 Dec 2017 00:03:56 +0000 (01:03 +0100)]
use find_program. Use env for multiple commands as it allows to split into string list.

8 years agouse env instead of bash
Félix Piédallu [Fri, 1 Dec 2017 23:50:41 +0000 (00:50 +0100)]
use env instead of bash

8 years agoUse formatting instead of weird path reconstruction
Félix Piédallu [Fri, 1 Dec 2017 14:57:41 +0000 (15:57 +0100)]
Use formatting instead of weird path reconstruction

8 years agoDispatch the custom_target in two custom_targets for cleaner dependency declaration.
Félix Piédallu [Fri, 1 Dec 2017 14:31:43 +0000 (15:31 +0100)]
Dispatch the custom_target in two custom_targets for cleaner dependency declaration.

8 years agoFix push_web, add index_html generation. TODO: simplify this someday
Félix Piédallu [Fri, 1 Dec 2017 13:47:10 +0000 (14:47 +0100)]
Fix push_web, add index_html generation. TODO: simplify this someday

8 years agoAdd linker script for symbols export
Félix Piédallu [Tue, 28 Nov 2017 14:53:04 +0000 (15:53 +0100)]
Add linker script for symbols export

8 years agosome small cleanup, export script for scp
Félix Piédallu [Sun, 26 Nov 2017 12:51:31 +0000 (13:51 +0100)]
some small cleanup, export script for scp

8 years agoadd docs. fix install libs. Seems finished.~
Félix Piédallu [Thu, 23 Nov 2017 20:43:16 +0000 (21:43 +0100)]
add docs. fix install libs. Seems finished.~

8 years agoadd extensions, tools
Félix Piédallu [Thu, 23 Nov 2017 17:18:56 +0000 (18:18 +0100)]
add extensions, tools

8 years agoAdd tests
Félix Piédallu [Thu, 23 Nov 2017 17:12:09 +0000 (18:12 +0100)]
Add tests

8 years agoFix build, links.
Félix Piédallu [Thu, 23 Nov 2017 17:01:10 +0000 (18:01 +0100)]
Fix build, links.

8 years agoAdded basic meson files
Félix Piédallu [Thu, 23 Nov 2017 16:58:37 +0000 (17:58 +0100)]
Added basic meson files

8 years agobabl: make conversion to model double more generic
Øyvind Kolås [Sat, 18 Nov 2017 00:35:09 +0000 (01:35 +0100)]
babl: make conversion to model double more generic

Iterate over the components of the model, and fetch the relevant
component from the source format or use a filler value if not found.

Some changes by Debarshi Ray.

https://bugzilla.gnome.org/show_bug.cgi?id=790860

8 years agoCIE: refactor away some intermediate variables/assignments
Øyvind Kolås [Sat, 9 Dec 2017 22:38:38 +0000 (23:38 +0100)]
CIE: refactor away some intermediate variables/assignments

8 years agoCIE: add CIE XYZ and CIE XYZ alpha models
Øyvind Kolås [Sat, 9 Dec 2017 19:51:38 +0000 (20:51 +0100)]
CIE: add CIE XYZ and CIE XYZ alpha models

Even more useful now with custom RGB primaries - and being able to use babl for
conversions when needed is convenient. This is with reference paths - which
means fast paths for double precision float - single precision would have to be
added for it to be used and higher throughput in most common scenarios.

8 years agotests: not all UNIX-like OSes have a libpthread.
Jehan [Mon, 4 Dec 2017 02:33:47 +0000 (03:33 +0100)]
tests: not all UNIX-like OSes have a libpthread.

In particular Android systems don't need to link with -lpthread
(actually the link would fail with "ld: cannot find -lpthread").
Use the $(THREAD_LIB) variable which is set correctly during configure
since commit c02af82.

8 years agoCIE: Simplify code
Debarshi Ray [Sat, 18 Nov 2017 01:09:03 +0000 (02:09 +0100)]
CIE: Simplify code

Exploit the fact that fy is not needed to calculate the a and b
components. This is consistent with the other monochrome conversions.

8 years agoconfigure.ac: post release version bump
Øyvind Kolås [Wed, 15 Nov 2017 22:18:20 +0000 (23:18 +0100)]
configure.ac: post release version bump

8 years agoconfigure.ac: release 0.1.38
Øyvind Kolås [Wed, 15 Nov 2017 22:16:36 +0000 (23:16 +0100)]
configure.ac: release 0.1.38

8 years agoNEWS: update
Øyvind Kolås [Wed, 15 Nov 2017 22:15:25 +0000 (23:15 +0100)]
NEWS: update

8 years agobabl_pow_24f(): add missing float suffix
Edward E [Tue, 14 Nov 2017 04:43:29 +0000 (22:43 -0600)]
babl_pow_24f(): add missing float suffix

8 years agoCIE: Add "CIE L float"
Debarshi Ray [Thu, 9 Nov 2017 06:48:26 +0000 (07:48 +0100)]
CIE: Add "CIE L float"

Some of these conversions will be leveraged by gegl:shadows-highlights
which needs to go from "Y float" or "YaA float" to "CIE L float".

The conversion from "RGBA float" was added to aid "YaA float" to
"CIE L float" fishes. They go via:
  "YaA float"     to "RaGaBaA float"
  "RaGaBaA float" to "RGBA float"
  "RGBA float"    to "Y float"
  "Y float"       to "CIE L float"

A direct conversion from "YaA float" to "Y float" in simple C is
hindered by the need to check every pixel's alpha value to avoid
dividing by zero. The pipeline stalls make it lose out to the look-up
table and SIMD based RGB conversions to unassociated alpha.

However, we can trivially cut out the third step and still reduce some
memory traffic.

https://bugzilla.gnome.org/show_bug.cgi?id=790111

8 years agobabl: fix memory leaks on error paths
Tobias Stoeckmann [Fri, 13 Oct 2017 16:32:52 +0000 (18:32 +0200)]
babl: fix memory leaks on error paths

The database-focused functions of babl-cache are prone to
memory leaks when errors occur.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agoextensions: protect another conversion against /0.0
Øyvind Kolås [Fri, 10 Nov 2017 09:44:21 +0000 (10:44 +0100)]
extensions: protect another conversion against /0.0

8 years agoextensions: protect gray unpremuls from gggl against division by 0.0
Øyvind Kolås [Fri, 10 Nov 2017 09:34:57 +0000 (10:34 +0100)]
extensions: protect gray unpremuls from gggl against division by 0.0

8 years agoconfigure.ac: post release version bump
Øyvind Kolås [Fri, 10 Nov 2017 00:08:10 +0000 (01:08 +0100)]
configure.ac: post release version bump

8 years agorelease: 0.1.36
Øyvind Kolås [Fri, 10 Nov 2017 00:05:32 +0000 (01:05 +0100)]
release: 0.1.36

8 years agoNEWS: update for 0.1.36
Øyvind Kolås [Fri, 10 Nov 2017 00:03:37 +0000 (01:03 +0100)]
NEWS: update for 0.1.36

8 years agoCIE: Make the Lab to RGB fast paths work with non-sRGB primaries
Debarshi Ray [Tue, 7 Nov 2017 09:52:44 +0000 (10:52 +0100)]
CIE: Make the Lab to RGB fast paths work with non-sRGB primaries

This is similar to commit 72a074df6545fcb3.

https://bugzilla.gnome.org/show_bug.cgi?id=790011

8 years agoCIE: Make the Lab to RGB fast paths as accurate as the reference
Debarshi Ray [Tue, 7 Nov 2017 09:38:12 +0000 (10:38 +0100)]
CIE: Make the Lab to RGB fast paths as accurate as the reference

This is similar to commit e17807f235557d5d.

https://bugzilla.gnome.org/show_bug.cgi?id=790011

8 years agobabl, sse2-float: fall back to slow, accurate path for large pow-2.4 inputs
Ell [Tue, 7 Nov 2017 20:44:39 +0000 (15:44 -0500)]
babl, sse2-float: fall back to slow, accurate path for large pow-2.4 inputs

The approximations we use for pow_24() and pow_1_24() diverge from
the actual function for large-enough input values.  This can lead
not just to inaccurate results, but also to infinities and NaNs,
especially when multiple conversions are strung in a row.

When the input value is large enough to produce notable divergence
(the difference between the approximate and actual values is ~1% at
the chosen limits,) fall back to a slower, but more accurate
version.

For the SSE2 float conversions, this results in an increase of ~5%
in conversion time, when all values are below the limit.  When most
values are above the limit, performance can be 10x slower or worse.

8 years agoexport-symbols: add babl_format_exists
Øyvind Kolås [Tue, 31 Oct 2017 19:48:23 +0000 (20:48 +0100)]
export-symbols: add babl_format_exists

8 years agobabl: add babl_format_exists
Øyvind Kolås [Tue, 31 Oct 2017 19:48:23 +0000 (20:48 +0100)]
babl: add babl_format_exists

A function to check if a specific format - by name - is already known by babl.
Should be used in conjunction with babl_format() for user supplied format
strings.

8 years agoCIE: Make the RGB to Lab fast paths work with non-sRGB primaries
Debarshi Ray [Tue, 31 Oct 2017 11:20:45 +0000 (12:20 +0100)]
CIE: Make the RGB to Lab fast paths work with non-sRGB primaries

The older constants were tied to sRGB primaries. Using the matrices
from the Babl space removes this restriction.

https://bugzilla.gnome.org/show_bug.cgi?id=789695

8 years agoCIE: Make the RGB to Lab fast paths as accurate as the reference
Debarshi Ray [Tue, 31 Oct 2017 08:43:53 +0000 (09:43 +0100)]
CIE: Make the RGB to Lab fast paths as accurate as the reference

The matrices used by the fast paths to convert from RGB to XYZ didn't
exactly match the reference matrices in the Babl space. This caused a
measurable error in their output.

https://bugzilla.gnome.org/show_bug.cgi?id=789695

8 years agoCIE: Use cbrt instead of pow for the reference XYZ to LAB conversion
Debarshi Ray [Tue, 31 Oct 2017 08:36:39 +0000 (09:36 +0100)]
CIE: Use cbrt instead of pow for the reference XYZ to LAB conversion

The fast-paths use an inlining-friendly version of cbrt(3). Using
something similar removes superficial differences between the two
conversion paths. It's not like the C library's cbrt(3) will perform
any worse than its own pow(3).

https://bugzilla.gnome.org/show_bug.cgi?id=789695

8 years agoCIE: Add conversion from "RGBA float" to "CIE Lab float"
Debarshi Ray [Sun, 29 Oct 2017 12:52:26 +0000 (13:52 +0100)]
CIE: Add conversion from "RGBA float" to "CIE Lab float"

Conversions from "RaGaBaA float" to "CIE Lab float", as seen when
using gegl:shadows-highlights" go via:
  "RaGaBaA float" to "RGBA float"
  "RGBA float"    to "RGB float"
  "RGB float"     to "CIE Lab float"

A direct conversion from "RaGaBaA float" to "CIE Lab float" in simple
C is hindered by the need to check every pixel's alpha value to avoid
dividing by zero. The pipeline stalls make it lose out to the look-up
table and SIMD based conversions to unassociated alpha.

However, we can trivially cut out the second step and still reduce
some memory traffic.

https://bugzilla.gnome.org/show_bug.cgi?id=789695

8 years agobabl: use snprintf instead of sprintf
Tobias Stoeckmann [Tue, 24 Oct 2017 18:02:15 +0000 (20:02 +0200)]
babl: use snprintf instead of sprintf

Using sprintf with environment variables is dangerous, because it can
easily lead to out of boundary writes on heap space.

While at it, replace sprintf calls with snprintf where proper
boundary checks are possible and required.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agobabl: properly handle large files on 32 bit systems
Tobias Stoeckmann [Fri, 13 Oct 2017 16:39:02 +0000 (18:39 +0200)]
babl: properly handle large files on 32 bit systems

If large file support is enabled on 32 bit systems, it is possible
to trigger an out of boundary write with files larger than 2 GB.

Always check if fseek and ftell are successful and if the file is
small enough to fit into memory.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agobabl: always end strncpy strings with NUL
Tobias Stoeckmann [Fri, 13 Oct 2017 17:25:01 +0000 (19:25 +0200)]
babl: always end strncpy strings with NUL

The function strncpy(3) does not guarantee to end the destination string
with NUL character if not enough space was available. This could happen
on systems which allow paths which are longer than 4096 characters.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>